<?php require_once 'header.php';?>    
<!-- DataTables Responsive CSS -->
    <link href="sb2/vendor/datatables-responsive/dataTables.responsive.css" rel="stylesheet">

        <!-- Page Content -->
        <div id="page-wrapper">
            <div class="container-fluid">
            <div class="row">
                <div class="col-lg-12">
                    <div class="panel panel-default">
                        <div class="panel-heading">
                        <?php echo XXF_BACK?>
                            <span class="xxf_red">{{$pname}}</span> 课程管理 <br>
                            <input type="text" id="riqi" placeholder="上课日期"  title="上课日期" name="x">
                            <select id="kenum" name="x">
                            	<option value="0">第几课</option>
                            	<option value="1">1</option>
                            	<option value="2">2</option>
                            	<option value="3">3</option>
                            </select>
                            [
                            <a href="pxy_kcset/pid/{{$pid}}"><i class="fa fa-fw fa-plus-square"></i></a>
                            <select id="pkid" name="x">
                            	<option value="0">选择课程</option>
                            	<?php foreach ($ke as $row){ ?>
                                <option value="<?php echo $row['id']?>"><?php echo $row['kname'];?></option>
                                <?php }?>
                            </select>
                            ] 
                            [
                            <a href="pxy_jsset/pid/{{$pid}}"><i class="fa fa-fw fa-plus-square"></i></a>
                            <select id="pjid" name="x">
                            	<option value="0">选择教师</option>
                            	<?php foreach ($result as $row){ ?>
                                <option value="<?php echo $row['id']?>"><?php echo $row['tname'];?></option>
                                <?php }?>
                            </select>
                            ]
                            <input type="hidden" value="{{$pid}}" name="x" id="pid">
							<input type="button" id="add" value="添加" onclick="add()">
                        </div>
                        <!-- /.panel-heading -->
                        <div class="panel-body">
                            <table width="100%" class="table table-striped table-bordered table-hover" id="dataTables-example">
                                <thead>
                                    <tr>
                                        <th>日期</th>
                                        <th>第几节课</th>
                                        <th>课程名称</th>
                                        <th>教师</th>
                                        <th>操作</th>
                                    </tr>
                                </thead>
                                <tbody>
                                	<?php
                                	$i=0;
                                	foreach ($pjk as $row){$i++;
                                	?>
                                    <tr class="<?php echo $i%2==0?"even":"odd";?> gradeA" id='<?php echo $row['id'];?>'>
                                        <td><?php echo $row['riqi'];?></td>
                                        <td><?php echo $row['kenum'];?></td>
                                        <td><?php echo $row['kname'];?></td>
                                        <td><?php echo $row['tname'];?></td>
                                        <td><a href="javascript:del(<?php echo $row['id']?>)">删除</a></td>
                                    </tr>
                                	<?php 
                                	}
                                	?>
                                </tbody>
                            </table>
                        </div>
                        <!-- /.panel-body -->
                    </div>
                    <!-- /.panel -->
                </div>
                <!-- /.col-lg-12 -->
                        
            <!-- /.row -->
             </div>
        </div>
        <!-- /#page-wrapper -->
  </div>
        <!-- DataTables JavaScript -->
<?php require_once 'bottom.php';?>
    <script src="sb2/vendor/datatables/js/jquery.dataTables.js"></script>
    <script src="sb2/vendor/datatables-plugins/dataTables.bootstrap.min.js"></script>
    <script src="sb2/vendor/datatables-responsive/dataTables.responsive.js"></script>
    <script>
    $(document).ready(function() {
        $('#dataTables-example').DataTable({
            responsive: true,
            "aaSorting": [[ 0, "desc" ]],
            "aLengthMenu": [ 100,50,25,10]
        });
    });
   $("#riqi").click(function(){$(this).xrili();});
    function del(id){
		$.xdel("peixun_jk",id);
    }
    function add(){
    	var pkid = $("#pkid").val();
    	var pjid = $("#pjid").val();
    	var kenum=$("#kenum").val();
    	var riqi=$.trim($("#riqi").val());
 		if(pkid=="0"||pjid=="0"||kenum=="0"||riqi.length<1){
			$.xalert("请将信息填写完整！");return false;
 	 	}
    	$.xconfirm("确定添加？",function(data){
 			if(data){
 				$.xtodb("add","peixun_jk",$("[name='x']"),"pid_riqi_kenum_pjid_pkid",function(data){//增加数据，数据库，操作相关form，验证列不能重复，回调
 					if(data==0){
 						$.xloading(0);
 						$.xalert("添加失败");
 					}else{
 						window.location.reload();
 					}
 				});
			} 
		});
    }    
    </script>